//
//  LLShoppingCartBottomView.m
//  LoveLove
//
//  Created by 肖兰月 on 2019/4/9.
//  Copyright © 2019 wkf. All rights reserved.
//

#import "LLShoppingCartBottomView.h"

@interface LLShoppingCartBottomView ()
@property (strong, nonatomic) LLButton *selecteAllBtn;
@property (strong, nonatomic) UILabel *totalFeeLbl;
@property (strong, nonatomic) LLButton *settleBtn;
@end

@implementation LLShoppingCartBottomView

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self initSubViews];
    }
    return self;
}

- (void)initSubViews {
    _selecteAllBtn = [LLInitBaseViewTool buttonWithTitle:@"全选" image:@"unselected" titleColor:LLColorRGB(100) font:13];
    _selecteAllBtn.frame = CGRectMake(0, (self.height-30)/2.0, 90, 30);
    [_selecteAllBtn setImage:[UIImage imageNamed:@"selected"] forState:UIControlStateSelected];
    _selecteAllBtn.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 15);
    [_selecteAllBtn addTarget:self action:@selector(selecteBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:_selecteAllBtn];
    
    _totalFeeLbl = [LLInitBaseViewTool labelWithText:nil textColor:nil font:0 textAlignment:NSTextAlignmentRight];
    _totalFeeLbl.frame = CGRectMake(_selecteAllBtn.right + 5, 25, self.width-110-_selecteAllBtn.right-5, 20);
    [self addSubview:_totalFeeLbl];
    
    _settleBtn = [LLInitBaseViewTool buttonWithTitle:@"结算（0）" image:nil titleColor:UIColor.whiteColor font:18];
    _settleBtn.frame = CGRectMake(self.width-96-10, 15, 100, 40);
    _settleBtn.backgroundColor = LLColor(225, 0, 0);
    _settleBtn.layer.cornerRadius = 20;
    [_settleBtn addTarget:self action:@selector(settleBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:_settleBtn];
}

- (void)setAllSelected:(BOOL)allSelected {
    _allSelected = allSelected;
    self.selecteAllBtn.selected = allSelected;
}

- (void)setTotalFee:(NSString *)totalFee {
    _totalFee = totalFee;
    _totalFeeLbl.attributedText = [NSAttributedString attributedStringsWithFrontText:@"合计：" frontFont:13 frontColor:LLColorRGB(0) backText:totalFee backFont:19 backColor:LLColor(231, 11, 11) middleText:@"¥" middleFont:13 middleColor:LLColor(231, 11, 11)];
}

- (void)setCountStr:(NSString *)countStr {
    _countStr = countStr;
    [_settleBtn setTitle:[NSString stringWithFormat:@"结算（%@）",countStr] forState:0];
}

- (void)selecteBtnClick {
    if ([self.delegate respondsToSelector:@selector(bottomViewDidClickSelecte:)]) {
        [self.delegate bottomViewDidClickSelecte:self];
    }
}

- (void)settleBtnClick {
    if ([self.delegate respondsToSelector:@selector(bottomViewDidClickSettle)]) {
        [self.delegate bottomViewDidClickSettle];
    }
}

@end
